import {createRouter, createWebHistory} from "vue-router";
import Login from "@/views/Login.vue";
import Layout from "@/views/Layout.vue";
import UserInfo from "@/views/user/UserInfo.vue";
import UserList from "@/views/user/UserList.vue";
import RestPassword from "@/views/user/RestPassword.vue";
import MarketList from '../views/market/MarketList.vue';


// 定义路由关系
const routes = [
    {path: '/login', component: Login},  // 一级路由
    {
        path: '/',
        redirect: '/login',  // 重定向
        component: Layout,
        // 子路由
        children: [
            {path: '/user/list', name: "userList", component: UserList}, // 标记需要管理员权限},
            {path: '/user/info', name: "info", component: UserInfo}, // 基本信息页面路由
            {path: '/user/resetPassword', name: "resetPassword", component: RestPassword}, // 重置密码页面路由
            {path: '/goods/list', name: "goodsList", component: () => import("../views/goods/GoodsList.vue")},
            {path: '/index', name: "index", component: () => import("../views/index.vue")},
            {path: '/mygoods/list', name: "mygoodsList", component: () => import("../views/mygoods/MyGoodsList.vue")},
            {path:'/market/list',name:'MarketList',component:()=>import('../views/market/MarketList.vue')}
        ]
    },
]

// 创建路由器
const router = createRouter({
    history: createWebHistory(), // 路由模式
    routes: routes
})

//导出暴露
export default router
